﻿function SendEmailCode() {
    if ($("#txtemail").val() == "" || $("#txtemail").val() == null||$("#txtemail").val()==undefined)
    {
      return false;
    }

  $.get("/ajax/Account/SendEmailCode.ashx?email=" + $("#txtemail").val(), function (msg) {
        if (msg == "0") {
            art.dialog({
                lock: true,
                content: "验证码发送失败，请核实您的邮箱地址!"
            });
        } else {
            art.dialog({
                lock: true,
                content: "验证码已经发送到邮箱，请注意查收！",
                ok: function () {
                    var mailurl = getMailUrl($("#txtEmail").val().split('@')[1]);
                    window.open(mailurl);
                }
            });
        }

    })
    
}

function getMailUrl(domain) {
    var url = "";
    switch (domain) {
        case "gmail.com": url = "http://mail.google.com"; break;
        default: url = "http://mail." + domain; break;

    }
    return url;
}




function AddInfo() {
    var sex = document.getElementsByName("sex");
    for (var i = 0; i < sex.length; i++) {
        if (sex[i].checked == true) {
            $("#_sex").val(sex[i].value)
        }

    }
    var shenfen = document.getElementsByName("shenfen");
    for (var i = 0; i < shenfen.length; i++) {
        if (shenfen[i].checked == true)
            $("#_shenfen").val(shenfen[i].value)
    }
    $("#_DistrictStr").val($("#selectProvince").find("option:selected").val() + "," + $("#selectCity").find("option:selected").val() + "," + $("#selectArea").find("option:selected").val());
       
    $.ajax({
        type: "POST",
        url: "/ajax/Account/Register.ashx",
        data: $("form").serialize(),
        cache: false,
        dataType: "text",
        error: function () {
            art.dialog({
                lock: true,
                content: "网络延迟，请稍后！",
                time: 2
            });
        },
        success: function (msg) {
            if (msg == "1") {
                art.dialog({
                    lock: true,
                    content: "注册成功！",
                    time: 2
                });
                alert("成功");
                // location.href = "/Login/PersonDetial.aspx";
            } if (msg == "0") {
                art.dialog({
                    lock: true,
                    content: "失败！",
                    time: 2
                });
                alert("失败");
               // location.href = "/Login/Register.aspx";
            }
        }
    });

}  